home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / mail / thor201.lha / THOR_2.0 / thor.lha / scripts / BBBS.NComm.script < prev    next >
Text File  |  1995-05-15  |  8KB  |  422 lines

  1. ; $VER: BBBS.NComm.script 3.2 (3.2.95)
  2. ; BBBS NComm Script for THOR
  3. ; By Eivind Nordseth, Ultima Thule Software
  4.  
  5.     REQUEST OFF
  6.  
  7.     set $fixtimeout = ""
  8.     set $rengrab = ""
  9.     set $doctrlx = "FALSE"
  10.     set $done = "FALSE"
  11.  
  12.     cli $THORPath"bin/ScriptServ \""$BBSName"\" WRITECFG EV 7 EV 8 EV 11 EV 12"
  13.  
  14.     if exists "t:NoLogOut" then cli "delete >nil: t:NoLogOut"
  15.     if exists "t:DoLogOut" then cli "delete >nil: t:DoLogOut"
  16.  
  17.     varfile "t:"$BBSName".CONFIG"
  18.  
  19.     readvar $CfgVer
  20.     readvar $BBSID
  21.     readvar $BBSType
  22.     readvar $Path
  23.     readvar $PostConf
  24.     readvar $UpLoadDir
  25.     readvar $UserName
  26.     readvar $UserStreet
  27.     readvar $UserAddress
  28.     readvar $UserCountry
  29.     readvar $UserPhone
  30.     readvar $NewFiles
  31.     readvar $AutoPDnl
  32.     readvar $AutoLogoff
  33.     readvar $UseColors
  34.     readvar $AnsiMenues
  35.     readvar $Bulletins
  36.     varfile close
  37.  
  38.     if !$CfgVer == "3" then message "Incompatible version of ScriptServ"
  39.     if !$CfgVer == "3" then goto AllDone
  40.  
  41.     cli "delete >nil: \"t:"$BBSName".CONFIG\""
  42.  
  43.     set $LogFile = $Path"ScriptMsg.txt"
  44.  
  45.     when "\r\nNO CARRIER\r\n" goto AllDone
  46.  
  47.     autoxfer off ; Turn off G&R commands
  48.     autoup off   ; Turn off Zmodem autoupload
  49.     autodown on  ; Turn on Zmodem autodownload
  50.  
  51.     menuselect TRANSLATE 1 8 ; Use IBN character set
  52.     set $charset = "IBN"     ; Use IBN character set
  53.  
  54.     converse "FIRST name?" $UserName" Q\n"
  55.     converse "will echo):" "\p\n"
  56.  
  57.     when "--more--" send "C"
  58.     when "Trykk <enter>" send "\n"
  59.  
  60.     set $docmd = "CHAT N U L 0 MF 50 S IBN\n"
  61.     gosub DoCommand
  62.  
  63.     dwhen "Trykk <enter>"
  64.  
  65.     wait "Command"
  66.     set $doctrlx = "TRUE"
  67.  
  68.     if !exists "t:"$BBSName".EVENTS" then goto afterEvents
  69.     varfile "t:"$BBSName".EVENTS"
  70.  
  71. eventLoop:
  72.     set $done = "FALSE"
  73.  
  74.     readvar $eventnr
  75.     readvar $event
  76.  
  77.     if $eventnr == "EOF" then goto evLoopEnd
  78.     if $event   == "EOF" then goto evLoopEnd
  79.  
  80.     if $event == "7"  then gosub ConfigureBBS
  81.     if $event == "8"  then gosub SendUserInfo
  82.     if $event == "11" then gosub CommandEvent
  83.     if $event == "12" then gosub AutoLogOff
  84.  
  85.     if  $done == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" DONE "$eventnr
  86.     if !$done == "TRUE" then cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" ERROR "$eventnr
  87.  
  88.     goto eventLoop    
  89.  
  90. evLoopEnd:
  91.     varfile close
  92.  
  93. afterEvents:
  94.  
  95. ;***************** Set correct grab format
  96.  
  97.     set $docmd = "U GF H\n"
  98.     gosub DoCommand
  99.  
  100. ;***************** Send reply packet
  101.  
  102.     if !exists $UpLoadDir$BBSID".HRA" then goto AfterReplyPacket
  103.  
  104.     set $docmd = "Q MU\n"
  105.     gosub DoCommand
  106.  
  107.     set $reperr = "FALSE"
  108.     when "Hippo fatal error:" set $reperr = "TRUE"
  109.  
  110.     wait "Starting ZModem"
  111.     upload $UpLoadDir$BBSID".HRA",Z
  112.     gosub NoTimeout
  113.  
  114.     capture $Path"HIPPOMsg.txt"
  115.  
  116.     wait "Main Command"
  117.  
  118.     capture off
  119.     dlwhen
  120.  
  121.     if $reperr == "TRUE" then goto RepFileFail
  122.  
  123.     cli "delete >nil: "$UpLoadDir$BBSID".HRA"
  124.     cli "delete >nil: "$Path"HIPPOMsg.txt"
  125.  
  126.     cli "run >nil: "$THORPath"bin/ScriptServ \""$BBSName"\" PACKAGEDONE"
  127.  
  128.     set $doctrlx = "TRUE"
  129.     goto AfterReplyPacket
  130.  
  131. RepFileFail:
  132.     set $appendsource = $Path"HIPPOMsg.txt"
  133.     set $appenddest = $LogFile
  134.     gosub AppendFile
  135.     set $doctrlx = "TRUE"
  136.  
  137. AfterReplyPacket:
  138. ;***************** Grab messages
  139.     set $rengrab = "y"
  140.  
  141.     set $docmd = "R DUMP ALL\n"
  142.     gosub DoCommand
  143.  
  144.     when "<0>" goto grabd
  145.  
  146.     converse "Command" "SE\n"
  147.     gosub NoTimeout
  148.  
  149.     set $rengrab = "y"
  150.  
  151. grabd:
  152.     dlwhen
  153.  
  154. ;***************** Ready for logout
  155.  
  156.     if exists "t:DoLogOut" then goto DoLogOut
  157.  
  158.     if $AutoLogoff == "n" then goto NoLogOut
  159.  
  160.     if exists "t:NoLogOut" then goto NoLogOut
  161.  
  162. DoLogOut:
  163.     set $docmd = "CHAT A U L 30 MF 0\n"
  164.     gosub DoCommand
  165.  
  166.     set $docmd = "G Y N Y\n"
  167.     gosub DoCommand
  168.  
  169.     when "\r\nNO CARRIER\r\n" goto Hanged
  170.     delay 2
  171.     repeat
  172.     hangup
  173.     delay 2
  174.     until !CARRIER
  175.  
  176. Hanged:
  177.     dlwhen
  178.     goto AllDone
  179.  
  180. NoLogOut:
  181.     set $docmd = "CHAT A U L 30 MF 0 W R\n"
  182.     gosub DoCommand
  183.  
  184.     dwhens
  185.     timeout 0
  186.  
  187. AllDone:
  188.     request on
  189.     end
  190.  
  191.  
  192. Hung:
  193.     beep
  194.     message "\nI think the board has hung."
  195.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  196.     delay 20
  197.     beep
  198.     message "\nWARNING: Logout in progress.\n"
  199.     hangup
  200.     goto AllDone
  201.  
  202. SysOp:
  203.     send "Sorry, you are trying to chat with a script.\n"
  204.     send "Please put me back to the BBS at once.\n"
  205.     set $Timeouts = "0"
  206.     wait "SYSOP is going offline!"
  207.     set $Timeouts = "0"
  208.     return
  209.  
  210.  
  211. ;************************************************
  212. DoCommand:
  213.     if $doctrlx == "TRUE" then send "^Z"
  214.     converse "Command" $docmd
  215.  
  216.     if !$rengrab == "" then gosub RenameGrab
  217.     if !$fixtimeout == "" then gosub SetupTimeout
  218.  
  219.     set $doctrlx = "FALSE"
  220.     return
  221.  
  222. ;************************************************
  223. NoTimeout:
  224.     set $fixtimeout = "d"
  225.     timeout 0
  226.     return
  227.  
  228. SetupTimeout:
  229.     set $fixtimeout = ""
  230.     set $Timeouts = "0"
  231.     timeout 60 gosub SendCTRLX
  232.     return
  233.  
  234. SendCTRLX:
  235.     set $fixtimeout = "d"
  236.     if $Timeouts == "2" then timeout 20 gosub Hung
  237.     if $Timeouts == "2" then send "^Z"
  238.  
  239.     if $Timeouts == "1" then send $docmd
  240.     if $Timeouts == "1" then set $Timeouts = "2"
  241.  
  242.     if $Timeouts == "0" then send "^Z"
  243.     if $Timeouts == "0" then set $Timeouts = "1"
  244.     return
  245.  
  246. Hung:
  247.     beep
  248.     message "\nI think the board has hung."
  249.     message "\nTurn off this script within 20 seconds to stop me from logging out !!"
  250.     delay 20
  251.     beep
  252.     message "\nWARNING: Logout in progress.\n"
  253.     hangup
  254.     goto AllDone
  255.  
  256. ;************************************************
  257. RenameGrab:
  258.     set $rengrab = ""
  259.     cli $THORPath"bin/ScriptServ \""$BBSName"\" RENAMEGRAB"
  260.     cli "run >nil: sys:rexxc/rx 'address THOR.01 RESCAN'"
  261.     return
  262.  
  263. ;************************************************
  264. Startlogfile:
  265.     if !exists $LogFile then write $LogFile "Messages from script:\n"
  266.     write $LogFile "Error in event nr "$eventnr":\n"
  267.     return
  268.  
  269. ;************************************************
  270. ; Append a file to the en of the other.
  271. ; Uses variables:
  272. ;  $appendsource - File to append.
  273. ;  $appenddest   - Destination.
  274. AppendFile:
  275.     if !exists $appenddest then goto afNotExists
  276.  
  277.     cli "join >nil: \""$appenddest"\" \""$appendsource"\" TO \""$appenddest".tmp\""
  278.     cli "delete >nil: \""$appenddest"\""
  279.     cli "rename >nil: \""$appenddest".tmp\" \""$appenddest"\""
  280.     cli "delete >nil: \""$appendsource"\""
  281.     return    
  282.  
  283. afNotExists:
  284.     cli "rename >nil: \""$appendsource"\" \""$appenddest"\""
  285.     return
  286.  
  287.  
  288. ;************************************************
  289. ; Do a custom command
  290. ; Uses variables:
  291. ;  $commandstring - Command to execute.
  292. CommandEvent:
  293.     readvar $commandstring
  294.  
  295.     write $LogFile "Executing custom command:\n"
  296.  
  297.     set $docmd = $commandstring"\n"
  298.     gosub DoCommand
  299.  
  300.     capture $LogFile
  301.  
  302.     gosub NoTimeout
  303.  
  304.     when "File Command"  goto CmdEvDone
  305.     when "Main Command"  goto CmdEvDone
  306.     when "Utility Command" goto CmdEvDone
  307.     when "SYSOP Command" goto CmdEvDone
  308.     when "SIGOP Command" goto CmdEvDone
  309.     when "Misc Command"  goto CmdEvDone
  310.     
  311.     wait "Read Command"
  312.  
  313. CmdEvDone:
  314.     dlwhen
  315.     dlwhen
  316.     dlwhen
  317.     dlwhen
  318.     dlwhen
  319.     dlwhen
  320.  
  321.     capture off
  322.     write $LogFile "\n"
  323.     set $done = "TRUE"
  324.     set $doctrlx = "TRUE"
  325.     return
  326.  
  327. ;************************************************
  328. ; Send user info
  329. ; Uses variables:
  330. ;    $msgfile    - file user info is in
  331. SendUserInfo:
  332.     readvar $msgfile
  333.  
  334.     set $docmd = "U RES\n"
  335.     gosub DoCommand
  336.  
  337.     wait "--7-"
  338.     send "^KC"
  339.  
  340.     ascsend $Path$msgfile
  341.     send "\w^Z"
  342.  
  343.     wait "Command"
  344.  
  345.     set $done = "TRUE"
  346.     set $doctrlx = "TRUE"
  347.  
  348.     return
  349.  
  350. ;************************************************
  351. ; Set up BBS configuration
  352. ConfigureBBS:
  353.  
  354.     set $docmd = "U TE ANSI\n"
  355.     gosub DoCommand
  356.  
  357.     set $docmd = "COL\n"
  358.     set $cfgset = $UseColors
  359.     gosub CfgEnable    
  360.  
  361.     set $docmd = "ED FSE\n"
  362.     gosub DoCommand
  363.  
  364.     set $docmd = "REV\n"
  365.     set $cfgset = "y"
  366.     gosub CfgEnable    
  367.  
  368.     set $docmd = "T Z\n"
  369.     gosub DoCommand
  370.     
  371.     set $docmd = "AF L\n"
  372.     gosub DoCommand
  373.  
  374.     set $docmd = "U A\n"
  375.     gosub DoCommand
  376.  
  377.     converse "street address" "^Z"$UserStreet"\n"
  378.     converse "code and state" "^Z"$UserAddress"\n"
  379.     
  380.     if $UserPhone == "" then set $UserPhone = "-"
  381.     converse "your phone number" "^Z"$UserPhone"\n"
  382.  
  383.     converse "date of birth" "\n"
  384.  
  385.     set $docmd = "R MODE Mark\n"
  386.     gosub DoCommand
  387.  
  388.     wait "Command"
  389.  
  390.     set $done = "TRUE"
  391.     set $doctrlx = "TRUE"
  392.  
  393.     return
  394.  
  395. CfgEnable:
  396.     set $scfenabled = "n"
  397.     when "enabled" set $scfenabled = "y"
  398.  
  399.     gosub DoCommand
  400.  
  401.     wait "Command"
  402.     dlwhen
  403.  
  404.     set $doctrlx = "TRUE"
  405.     if !$scfenabled == $cfgset then gosub DoCommand
  406.  
  407.     return
  408.  
  409. ;************************************************
  410. ; Set the autologoff flag.
  411. ; Uses variables:
  412. ;  $boolean - Logoff (y/n)
  413. AutoLogOff:
  414.     readvar $boolean
  415.  
  416.     set $AutoLogoff = "y"
  417.     if $boolean == "0" then set $AutoLogoff = "n"
  418.     set $done = "TRUE"
  419.  
  420.     return
  421.  
  422.